<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/10/5
  Time: 11:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>login</title>
  </head>
  <body>
  <form action="LoginServlet" method="post" id="commit" >
    用户名： <input type="text" name="username" id="username"/><br>
    自动登录：<input type="checkbox" name="dl" id="dl" value="on"/><br>
    <input type="submit" value="提交" />
  </form>
  <script>
    setTimeout(window.onload = function (){

      var cookies=document.cookie;
      var cookies2="";
      var cookies1="";
      var cookies3="";
      if (cookies!=""){
        cookies1=cookies.split("; ");
        cookies2=cookies1[0].split("=")
        cookies3=cookies1[1].split("=")
        cookies2=cookies2[1];
        cookies3=cookies3[1];
      }
      var username= cookies2;
      var dl=cookies3;
      if (username!=""&&dl==""){
        document.getElementById("username").value="";
      }else if(username!=""&&dl!=""){
        document.getElementById("username").value=username;
        document.getElementById("dl").checked=true
        document.getElementById("commit").submit();
      }else if(username==""&&dl==""){
        document.getElementById("username").value="";
        document.getElementById("dl").value="";
      }
    }, 3000);
  </script>
  </body>
</html>
